package com.zhihao.zhihaopicturebackend.service;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zhihao.zhihaopicturebackend.model.dto.user.UserLoginRequest;
import com.zhihao.zhihaopicturebackend.model.dto.user.UserPasswordModifyRequest;
import com.zhihao.zhihaopicturebackend.model.dto.user.UserQueryRequest;
import com.zhihao.zhihaopicturebackend.model.dto.user.UserRegisterRequest;
import com.zhihao.zhihaopicturebackend.model.entity.SystemUser;
import com.baomidou.mybatisplus.extension.service.IService;
import com.zhihao.zhihaopicturebackend.model.vo.LoginUserVO;
import com.zhihao.zhihaopicturebackend.model.vo.UserVO;

import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;
import java.util.List;

/**
* @author Jackson
* @description 针对表【system_user(用户表)】的数据库操作Service
* @createDate 2024-12-20 15:17:37
*/
public interface SystemUserService extends IService<SystemUser> {

    /**
     * 用户注册
     */
    Long userRegister(@Valid UserRegisterRequest userRegisterRequest);

    /**
     * 用户登录
     */
    LoginUserVO userLogin(@Valid UserLoginRequest userLoginRequest, HttpServletRequest request);

    /**
     * 获取脱敏的已登录用户信息(服务间可能也会调用)
     *
     * @param request
     * @return Session中保存的用户信息(未脱敏)
     */
    SystemUser getLoginUser(HttpServletRequest request);

    /**
     * 用户注销
     *
     * @param request
     */
    boolean userLogout(HttpServletRequest request);

    /**
     * 封装一层(表中用户信息--->脱敏后的用户信息(用户间调用))
     * @param user
     * @return
     */
    UserVO getUserVO(SystemUser user);

    /**
     * 批量转换
     * @param userList
     * @return
     */
    List<UserVO> getUserVOList(List<SystemUser> userList);

    /**
     * 是否为管理员
     *
     * @param user
     * @return
     */
    boolean isAdmin(SystemUser user);

    /**
     * 查询条件转化
     * @param userQueryRequest
     * @return
     */
    QueryWrapper<SystemUser> getQueryWrapper(UserQueryRequest userQueryRequest);

    /**
     * 密码加密
     * @param userPassword
     * @return 加密后的密码
     */
    String getEncryptPassword(String userPassword);

    Boolean modifyUserPassword(@Valid UserPasswordModifyRequest userPasswordModifyRequest, HttpServletRequest request);

}
